With popularization of terminal devices, demands for sharing a file such as a picture file, a video file, or a music file between terminal devices are ever-increasing. Currently, when a transmit end shares a file with a receive end, the file is usually shared in a classic Bluetooth or high-fidelity direct (Wi-Fi direct) manner.
When a file is shared in the classic Bluetooth manner, a user triggers a discovering party and a discovered party to perform Bluetooth scanning, and the discovering party and the discovered party respectively perform frequency hopping on 79 channels by using different sequences, until the two parties perform frequency hopping synchronously. The discovering party successfully discovers the discovered party through scanning, and obtains device information of the discovered party, the user chooses to connect to a device, and a connecting party pre-estimates a sequence of a connected party, sends a connection request, and transmits the file after a connection is established. It should be noted that, before the discovering party and the discovered party establish a Bluetooth connection in the classic Bluetooth manner, the discovering party and the discovered party can successfully discover, through scanning, peers only when the discovering party and the discovered party perform frequency hopping on 79 channels until the two parties perform frequency hopping synchronously. That is, when a file is shared in the classic Bluetooth manner, a Bluetooth connection is established in a relatively long time, and efficiency is relatively low. Additionally, a transmission speed in the classic Bluetooth manner is relatively low and is only 2.1 Mbps.
When a file is shared in the Wi-Fi direct manner, a sending party and a receiving party enter a scanning state, and stay on 2.4 G channels and 5 G channels respectively for a period of time to perform detection, a quantity of the 2.4 G channels plus a quantity of the 5 G channels is more than 20, and a scanning period is relatively long.
Therefore, it can be learned that, when a file is shared, regardless of whether the classic Bluetooth manner or the Wi-Fi direct manner is used, a party can discover a peer only when the party performs scanning on a relatively large quantity of channels before a connection is established. Therefore, currently, when a file is shared, there are problems that a sending party and a receiving party can discover peers only in a relatively long time before the sending party and the receiving party are connected, efficiency is low, and the like.